//
//  SourceList.h
//  SourceView
//
//  Created by Keith Duncan on 04/05/2007.
//  Copyright 2007 thirty-three. All rights reserved.
//

#import <Cocoa/Cocoa.h>

extern NSString *AFContentImagesBinding;

@class AFShadowTextCell, AFImageTextCell;
@protocol AFSourceListDelegateProtocol, AFSourceListDatasourceProtocol;

/*!
    @class		 SourceView
    @abstract    An iLife '08 style source view
    @discussion  This is a bindings driven view (see below) that displays a hierarchy of data
*/

/*!
 
 Exposed Bindings:
 
 // Required Bindings, these provide the content
 
 • NSContentBinding, the arrangedObjects object of an NSTreeController or another compatable controller
 • KDContentImagesBinding, the key path by which the images are retrieved
 • NSContentValuesBinding, the key path by which the item titles are retrieved
 
 // Optional Bindings
 
 • KDSelectionIndexPathBinding, only a single index path is used, it's singular because a user shouldn't be able to select multiple row in a source view 
 • NSSelectedValueBinding, this is the selected item's title
 
 */

@interface AFSourceList : NSView <AFKeyValueBinding> {
	id <AFSourceListDelegateProtocol> delegate;
	id <AFSourceListDatasourceProtocol> dataSource;
	
	NSMutableDictionary *_bindingInfo;
	
	AFShadowTextCell *_titleCell;
	AFImageTextCell *_contentsCell;
	
	CGFloat _rowHeight, _nodeSeparation;
	
	NSMutableSet *_expanded, *_expandable, *_disclosureButtons;
	NSCountedSet *_disclosureLevels;
}

@property (assign) IBOutlet id <AFSourceListDelegateProtocol> delegate;
@property (assign) IBOutlet id <AFSourceListDatasourceProtocol> dataSource;

@end

@protocol AFSourceListDelegateProtocol <NSObject>
 @optional
// Note: root children are NEVER selectable and you won't be queried
- (BOOL)sourceList:(AFSourceList *)view canSelectObject:(id)node;
// Note: root children without leaves are expected to be removed, return YES here to override this
- (BOOL)sourceList:(AFSourceList *)view shouldDisplayLeaf:(id)node;
@end

@protocol AFSourceListDatasourceProtocol <NSObject>
 @optional
// Note: you will only be asked about objects with children, root children default to NO like the 10.5 Finder
- (BOOL)sourceList:(AFSourceList *)view shouldDrawDisclosureForItem:(id)object;
@end
